<template>
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>
    <div class="app-container">
      <!-- <el-row :gutter="10" class="mb8">
        <el-col :span="1.5">
          <el-button type="primary" plain icon="el-icon-plus" size="mini" @click="handleAdd"
                     v-hasPermi="['develop:GoodsOrderIn:add']">新增
          </el-button>
        </el-col>
        <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
      </el-row>-->

      <el-table border v-loading="loading" :data="dataList" ref="table" :max-height="tableMaxHeight">
        <el-table-column type="index" label="序号" align="center" width="50"></el-table-column>
        <el-table-column label="出入库批次号" align="center" prop="rukuno" />
        <el-table-column label="出入库时间" align="center" prop="rukudate">
          <template slot-scope="scope">
            <span>{{ parseTime(scope.row.rukudate, '{y}-{m}-{d}') }}</span>
          </template>
        </el-table-column>
        <el-table-column label="生产单号" align="center" prop="factoryProdNo">
          <template slot-scope="scope">
            <el-tooltip class="item" content="点击查看详情" effect="dark" placement="left-start">
              <span @click="handleUpdateDetail(scope.row)" style="color: #00afff;cursor:pointer;">
                {{ scope.row.factoryProdNo }}</span>
            </el-tooltip>
          </template>
        </el-table-column>
        <!-- <el-table-column label="生产单号" align="center" prop="factoryProdId"  /> -->
        <el-table-column label="销售编号" align="center" prop="projectNo" />
        <!--<el-table-column label="客户名称" align="center" prop="customerName"  />-->
        <el-table-column label="库存编码" align="center" prop="params.goodsCode" />
        <el-table-column label="产品名称" align="center" prop="params.goodsName" show-overflow-tooltip />
        <el-table-column label="产品型号" align="center" prop="params.goodsModel" />
        <el-table-column label="是否自制" align="center" prop="isdo">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.isdo" :value="scope.row.isdo" />
          </template>
        </el-table-column>
        <el-table-column label="出入库状态" align="center" prop="type">
          <template slot-scope="scope">
            <dict-tag :options="dict.type.churuku_type" :value="scope.row.type" />
          </template>
        </el-table-column>
        <el-table-column label="供应商名称" align="center" prop="supplierName" />
        <el-table-column label="出入库单价" align="center" prop="goodsBuyPrice" />
        <el-table-column label="出入库数量" align="center" prop="daohuoCount" />
        <el-table-column label="出入库重量" align="center" prop="dun" />
        <el-table-column label="可用数量" align="center" width="160" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <span v-if="scope.row.canCount === 0"></span>
            <span v-else>{{ scope.row.canCount }}</span>
          </template>
        </el-table-column>
        <el-table-column label="出入库价格" align="center" prop="goodsBuyTotal" />
        <!--        <el-table-column label="总利润" align="center" prop="goodsProfit"  />-->
        <el-table-column sortable label="自制产品备注" align="center" prop="doremark" />
        <el-table-column sortable label="操作工" align="center" prop="douser" />
        <el-table-column label="备注" align="center" prop="remark" />
        <el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width">
          <template slot-scope="scope">
            <el-button size="mini" type="text" icon="el-icon-document"
              @click="handleQualityTest(scope.row)">质量检验</el-button>

            <el-button size="mini" type="text" v-if="scope.row.status = '1'" icon="el-icon-document"
              @click="zizhiList(scope.row)">自制记录</el-button>
          </template>
        </el-table-column>
      </el-table>

      <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
        @pagination="getList" />
    </div>
    <ProductInspectionBatchFormInfo @ok="getList" ref="productInspectionBatch" />
    <useMingxi-form-list @ok="getList" ref="useMingxiFormList"></useMingxi-form-list>
    <zizhi-form-list @ok="getList" ref="zizhiFormList"></zizhi-form-list>

    <factory-test-quality-all-ruku ref="qualityTestingAllRuku" @ok="getList"> </factory-test-quality-all-ruku>
    <goodsDoAll-form ref="goodsDoAllForm" @ok="getList"></goodsDoAll-form>

  </el-dialog>
</template>

<script>
import {
  deleteAction,
  downloadFile,
  getAction,
  getById
} from '@/api/manage'

import ProductInspectionBatchFormInfo from '@/views/develop/goodsSale/module/ProductInspectionBatchFormInfo'
import UseMingxiFormList from '@/views/develop/goodsSale/module/UseMingxiFormList'
import FactoryTestQualityAllRuku from "@/views/develop/factory/factoryTestQuality/FactoryTestQualityRuku.vue";
import ZizhiFormList from '@/views/develop/goodsSale/module/ZizhiFormList'
import GoodsDoAllForm from '@/views/develop/zizhi/GoodsDoAllForm'
export default {
  name: "ChurukuListFormInfo",
  dicts: ['churuku_type', 'isdo'],
  components: {
    FactoryTestQualityAllRuku,
    ProductInspectionBatchFormInfo,
    UseMingxiFormList,
    ZizhiFormList,
    GoodsDoAllForm
  },
  data() {
    return {
      title: "记录",
      open: false,
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      rows: [],
      // 非单个禁用
      single: true,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 销售信息管理表格数据
      dataList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        goodsId: null,
        goodsName: null,
        goodsBrand: null,
        status: "1",
        goodsUnitPrice: null,
        goodsCount: null,
        dateRange: "",
        orderByColumn: "rukudate",
        isAsc: "desc",
        params: {},
      },
      url: {
        listByGoodsId: '/lvRukumingxi/lvRukumingxi/list',
      },
      PrjNameOptions: [],
      tableMaxHeight: window.innerHeight - 320,
    };
  },
  created() {
    window.addEventListener('resize', this.getTableHeight);
  },
  destroyed() {
    window.removeEventListener('resize', this.getTableHeight)
  },
  methods: {
    handleUpdateDetail(row) {
      var data = {
        id: row.factoryProdId
      }
      this.$refs.goodsDoAllForm.show(data,1);
    },
    zizhiList(row) {
      this.$refs.zizhiFormList.show(row);
    },
    useMingxi(row) {
      this.$refs.useMingxiFormList.show(row);
    },
    showChuruku(order) {
      this.rows = order;
      let that = this;
      that.queryParams.goodsId = order.id;
      that.getList();
      that.open = true;
    },
    getTableHeight() {
      this.tableHeight = window.innerHeight - 320
    },
    /** 查询销售信息管理列表 */
    getList() {
      this.loading = true;
      getAction(this.url.listByGoodsId, this.queryParams).then(response => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
    },
    /** 检验批次 */
    handleQualityTest(row) {
      this.$refs.qualityTestingAllRuku.showByRukuDetail(row);
    }
  }
};
</script>
